class Solution {
public:
    vector<int> getAverages(vector<int>& nums, int k) {
        int n=nums.size();
        long long sum=0;
        vector<int> ans(n,-1);
        if(k*2+1>n) return ans;
        sum = accumulate(nums.begin(),nums.begin()+2*k+1,0LL);
        ans[k]=sum/(2*k+1);
        for(int i=k+1;i+k<n;++i)
        {
            sum=sum+nums[i+k]-nums[i-k-1];
            ans[i]=sum/(2*k+1);
        }
        return ans;
    }
};